package com.longge;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-04 02:02
 */
public class CountVowelStrings {
    ArrayList<String> res = new ArrayList<>();

    public int countVowelStrings(int n) {

        String[] strs = {"a", "e", "i", "o", "u"};
        String path = "";
        backtrack(path, n , strs);
        return res.size();
    }

    private void backtrack(String path, int n, String[] strs) {
        if (n == 0) {
            res.add(path);
            return;
        }
        for (String str : strs) {
            if (path.equals("") || isValid(path.charAt(path.length() - 1), str)){
                path += str;
                backtrack(path, n - 1, strs);
                path = "";
            }
        }

    }

    private boolean isValid(char charAt, String str) {
        char charAt1 = str.charAt(0);
        return Character.compare(charAt, charAt1) <= 0;
    }

    public static void main(String[] args) {
        new CountVowelStrings().countVowelStrings(2);
    }
}
